export const http_get_file_list_url = 'http://localhost:9000/sxfw/file/list';
export const http_upload_file_url = 'http://localhost:9000/sxfw/file/upload';
export const http_down_file_url = 'http://localhost:9000/sxfw/file/fileDown';


export function dynamicFun(script, model, key = '$') {
    if (!script) return false;
    const func = script.indexOf('return') >= 0 ? '{' + script + '}' : 'return (' + script + ')';
    const Fn = new Function(key, func);
    return Fn(model);
}

export function dateFormater(date, fmt) {
    const o = {
        'M+': date.getMonth() + 1,
        'd+': date.getDate(),
        'H+': date.getHours(),
        'm+': date.getMinutes(),
        's+': date.getSeconds(),
        'q+': Math.floor((date.getMonth() + 3) / 3),
        'S': date.getMilliseconds(),
    };
    if (/(y+)/.test(fmt))
        fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp('(' + k + ')').test(fmt))
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)));
    return fmt;
}

